export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

export function validateUsername(rule, value, callback) {
  var uPattern = /^[a-zA-Z0-9]{4,16}$/;
  if(uPattern.test(value)){
    callback()
  }else{
    callback(new Error("用户名由4到16位（字母，数字)组成"))
  }
}

export function validatePassword(rule, value, callback) {
  var uPattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/
  if(uPattern.test(value)){
    callback()
  }else{
    callback(new Error("密码最低8位,且包含大写小写数字"))
  }
}

export function validateAmount(rule, value, callback) {
  var uPattern =/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
  if(uPattern.test(value)){
    callback()
  }else{
    callback(new Error("金额格式错误"))
  }
}

